package com.kamistoat.meimeimall.meimeimallcoupon.controller;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.kamistoat.meimeimall.common.annotation.DubboAndHTTPExceptionCatch;
import com.kamistoat.meimeimall.common.annotation.LoginRequired;
import com.kamistoat.meimeimall.meimeimallcoupon.dubbo.CouponDubboInterfaceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.kamistoat.meimeimall.meimeimallcoupon.entity.SpuBoundsEntity;
import com.kamistoat.meimeimall.meimeimallcoupon.service.SpuBoundsService;
import com.kamistoat.meimeimall.common.utils.R;


/**
 * 商品spu积分设置
 *
 * @author kamistoat
 * @email linjianshanke@163.com
 * @date 2021-09-12 16:19:47
 */
@Api(tags="商品SPU积分数据库操作")
@RestController
@RequestMapping("spubounds")
public class SpuBoundsController {
    protected Logger logger = LoggerFactory.getLogger(SpuBoundsController.class);

    @Autowired
    SpuBoundsService spuBoundsService;
    @Autowired
    CouponDubboInterfaceImpl couponDubboInterface;

    /**
     * 查询商品的积分
     */
    @ApiOperation("查询商品的积分")
    @GetMapping("get_bounds_by_spuId")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public BigDecimal[] getBoundsBySpuId(@RequestParam Long spuId) {
        R boundsBySpuIdR = couponDubboInterface.getBoundsBySpuId(spuId);
        if (boundsBySpuIdR.getCode() != 0) {
            logger.error(boundsBySpuIdR.getMsg());
        }
        return (BigDecimal[]) boundsBySpuIdR.get("bounds");
    }

    /**
     * 列表
     */
    @ApiOperation("从数据库获取列表")
    @GetMapping("/list")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R list(@RequestParam Map<String, Object> params) {
        return R.ok();
    }


    /**
     * 信息
     */
    @ApiOperation("从数据库查询指定的POJO")
    @GetMapping("/spu_bounds_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R info(@RequestParam("id") Long id) {
        return R.ok();
    }

    /**
     * 保存
     */
    @ApiOperation("向数据库保存POJO")
    @PutMapping("/spu_bounds_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R save(@RequestBody SpuBoundsEntity spuBounds) {
        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("向数据库更新POJO")
    @PostMapping("/spu_bounds_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R update(@RequestBody SpuBoundsEntity spuBounds) {
        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("从数据库删除指定POJO")
    @DeleteMapping("/spu_bounds_info")
    @LoginRequired
    @DubboAndHTTPExceptionCatch
    public R delete(@RequestBody Long[] ids) {
        return R.ok();
    }

}
